home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / rpg / crossfir.92 / crossfir / crossfire-0.92.5 / crossedit / Cnv / Cnv.h next >
C/C++ Source or Header  |  1996-07-24  |  5KB  |  172 lines

  1. /*
  2.  * Cnv.h - generic GUI utilities
  3.  * Copyright (C) 1993 Petri Heinila
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  * Author can be connected by email from hevi@lut.fi
  20.  */
  21.  
  22. #ifndef _Cnv_h
  23. #define _Cnv_h
  24.  
  25. #include <Posix.h>
  26. #include <Xaw.h>
  27. #include <Ansi.h>
  28. #include <config.h>
  29. #include <includes.h>
  30.  
  31. /*
  32.  * generic macros
  33.  */
  34. #define pathcpy(dst,src) {strncpy(dst,src,PATH_MAX);dst[PATH_MAX]='\0';}
  35. #define namecpy(dst,src) {strncpy(dst,src,NAME_MAX);dst[NAME_MAX]='\0';}
  36.  
  37. /*
  38.  * menu
  39.  */ 
  40. typedef struct CnvMenuRec {
  41.     char *label;
  42.     void (*func) (Widget, XtPointer, XtPointer);
  43. } CnvMenuRec;
  44. extern Widget CnvMenu(String, Widget,CnvMenuRec[], XtPointer);
  45.  
  46. /**********************************************************************
  47.  * CnvPath
  48.  **********************************************************************/
  49.  
  50. #define EntryMax (_POSIX_ARG_MAX / 2)
  51.  
  52. typedef enum {
  53.   CnvPathHold,
  54.   CnvPathOk,
  55.   CnvPathCancel
  56. } CnvPathResponce;
  57.  
  58. /*
  59.  * 
  60.  */
  61. typedef struct CnvPath {
  62.     Widget shell;               /* shell widget */
  63.     Widget dirList;             /* list widget for directories */
  64.     Widget fileList;            /* list widget for files */
  65.     Widget cwd;                 /* label widget for current working dir */
  66.     Widget text;                /* text field */
  67.     CnvPathResponce hold;          /* for internal use */
  68.     String dirTable[EntryMax];  /* table of dirnames, alloc dyn */
  69.     String fileTable[EntryMax]; /* table of filename, alloc dyn */
  70.     Cardinal fileNro;           /* number of files in current directory */
  71.     Cardinal dirNro;            /* number of directories in current dir */
  72.     /* char dirname[PATH_MAX+1];  name of current directory, abs. */
  73.     char current[PATH_MAX+1];   /* LibDir/MapDir<current> */
  74.     char filename[NAME_MAX+1];  /* last selected file, rel to dir */
  75.     char root[PATH_MAX+1];      /* directory names are prefixed by this */
  76. } *CnvPath;
  77.  
  78. extern CnvPath CnvPathCreate (String name,String root, String dir);
  79. extern void CnvPathDestroy ( CnvPath self );
  80. extern Boolean CnvPathNoAccess ( Widget w, String path );
  81. extern Boolean CnvPathNoWrite ( Widget w, String path );
  82. extern CnvPathResponce CnvPathSelect ( CnvPath self );
  83.  
  84.  
  85. /**********************************************************************
  86.  * CnvFiles
  87.  **********************************************************************/
  88.  
  89. typedef void (*CnvFilesProc)(XtPointer client,String path);
  90.  
  91. typedef struct CnvFiles {
  92.   /* private */
  93.   Widget shell;             /* shellwidget containing menu */ 
  94.   String name;              /* menu name, to be not ambiguous */
  95.   char directory[PATH_MAX+1]; /* directory to get menu */
  96.   CnvFilesProc proc;           /* function when menu item selected */
  97.   XtPointer client;         /* package pointer */
  98.   /* public */
  99. } *CnvFiles; 
  100.  
  101. extern CnvFiles CnvFilesCreate(String,Widget,CnvFilesProc,XtPointer,String);
  102. extern void CnvFilesDestroy ( CnvFiles  );
  103. extern Widget CnvFilesRescan ( CnvFiles, String,Widget,String directory );
  104.  
  105. /**********************************************************************
  106.  * CnvBrowse
  107.  **********************************************************************/
  108. typedef struct CnvBrowse *CnvBrowse;
  109. /*
  110.  * call this function when finished editing
  111.  */
  112. typedef void (*CnvBrowseEditProc)(CnvBrowse self,XtPointer client,String str);
  113.  
  114. /*
  115.  * object for showing text 
  116.  */
  117. struct CnvBrowse {
  118.   Widget shell;
  119.   Widget text;
  120.   Widget file;
  121.   Widget ok;
  122.   Boolean isup;
  123.   CnvBrowseEditProc proc;
  124. };
  125.  
  126. typedef enum CnvBrowseReturn {
  127.   CnvBrowseOk,
  128.   CnvBrowseError
  129. } CnvBrowseReturn;
  130.  
  131. /*
  132.  * inteface
  133.  */
  134. extern CnvBrowse CnvBrowseCreate ( String name, Widget parent,
  135.                   CnvBrowseEditProc proc);
  136. extern void CnvBrowseDestroy ( CnvBrowse self );
  137. extern void CnvBrowseShowFile ( CnvBrowse self, String file );
  138. extern void CnvBrowseShowString ( CnvBrowse self, String str );
  139. extern void CnvBrowseEditString ( CnvBrowse self, String str );
  140.  
  141. /**********************************************************************
  142.  * Cnv
  143.  **********************************************************************/
  144. typedef struct Cnv {
  145.     Widget shell;      /* application level shell widget */
  146.     struct {
  147.     Pixmap excloff;
  148.     Pixmap exclon;
  149.     Pixmap flagoff;
  150.     Pixmap flagon;
  151.     Pixmap notify;  /* face for CnvNotify */
  152.     Pixmap prompt;  /* face for CnvPrompt */
  153.     Pixmap submenu;
  154.     } xbm;
  155. } *Cnv;
  156. extern Cnv cnv;        /* this is global for all */
  157.  
  158. /*
  159.  * utility functions
  160.  */
  161. extern void CnvCenterWidget ( Widget w );
  162. extern void CnvDie ( Widget self, String msg );
  163. extern Widget CnvGetShell ( Widget child );
  164. extern int CnvNotify (String msg, ... );
  165. extern int CnvPrompt ( String msg, String sgg, String ans, ...);
  166. extern void CnvWarn ( Widget self, String msg );
  167. extern void CnvInitialize(Widget shell);
  168. extern CnvPathResponce CnvPathSelectAbs(CnvPath self,String path);
  169.  
  170.  
  171. #endif    /* _Cnv_h */
  172.